﻿#include <iostream>
#include <Windows.h>
#include <string>
using namespace std;
enum zoneType { GMT=0, east1, east2, east3, east4, east5, east6, east7, east8, east9, east10, east11, east12, TIMEZONE12 =-11, west11, west10, west9, west8, west7, west6, west5, west4, west3,west2
};
class Time
{
private:
	int hrs, mins, secs;
public:
	Time();
	Time(int, int, int);
	~Time() {};
	void Set(int, int, int);
	void write() const;
	int Hours() const {return this->hrs; };
	int Minutes() const { return this->mins; };
	int Seconds() const { return this->secs; };
	Time operator++();
	Time operator--();
};
class ExtTime : public Time
{
private:
	zoneType zone;
public:
	ExtTime();
	ExtTime(int, int, int, zoneType);
	~ExtTime() {};
	void Set(int, int, int, zoneType);
	void write() const;
	ExtTime operator++();
	ExtTime operator--();
	zoneType Zone() const { return this->zone; }
};
class iWatch
{
	string name;
	ExtTime etime;
public:
	iWatch();
	iWatch(string, int,int, int, zoneType);
	void ChinaTime() const;
	void otherTime(zoneType) const;
};
Time::Time()
{
	SYSTEMTIME sys;
	GetLocalTime(&sys);
	this->hrs = sys.wHour;
	this->mins = sys.wMinute;
	this->secs = sys.wMinute;
}
Time::Time(int h, int m, int s)
{
	this->hrs = h;
	this->mins = m;
	this->secs = s;
}
void Time::Set(int h, int m, int s)
{
	this->hrs = h;
	this->mins = m;
	this->secs = s;
}
void Time::write() const
{
	cout << this->hrs << ":" << this->mins << ":" << this->secs << endl;
}
Time Time::operator++()
{
	++this->hrs;//下一个时区时间比现在多1h
	return *this;
}
Time Time::operator--()
{
	--(this->hrs);//上一个时区比现在少1h
	return *this;
}
ExtTime::ExtTime():Time()
{
	this->zone = east8;//默认是中国时间
}
ExtTime::ExtTime(int h, int m, int s, zoneType z):Time(h,m,s)
{
	this->zone = z;
}
void ExtTime::Set(int h,int m,int s,zoneType z)
{
	Time::Set(h, m, s);
	this->zone = z;
}
void ExtTime::write() const
{
	Time::write();
	cout << "Timezone: " << zone << endl;
}
ExtTime ExtTime::operator++()
{
	Time::operator++();
	int temp = zone;
	temp++;
	zone = static_cast<zoneType>(temp);
	return *this;
}
ExtTime ExtTime::operator--()
{
	Time::operator--();
	int temp = zone;
	temp--;
	zone = static_cast<zoneType>(temp);
	return *this;
}
iWatch::iWatch()
{
	name = "Ai's iWatch";
}
iWatch::iWatch(string name1, int h, int m, int s, zoneType z)
{
	this->name = name1;
	etime.Set(h, m, s, z);
}
void iWatch::ChinaTime() const
{
	cout << "ChinaTime:";
	this->etime.write();
}
void iWatch::otherTime(zoneType z) const
{
	int minus = z - this->etime.Zone();
	int time;
	if (this->etime.Hours() + minus < 0)
	{
		time = 24 + this->etime.Hours() + minus;
	}
	else
	{
		time = this->etime.Hours() + minus;
	}
	cout << "Time In The Timezone You Choose: ";
	cout << time << ":" << this->etime.Minutes() << ":" << this->etime.Seconds() << endl;
}
int main()
{
	Time t1;
	t1.write();
	Time t2(1, 1, 1);
	t2.write();
	t2.Set(2, 2, 2);
	t2.write();
	++t2;
	cout << "Hours: " << t2.Hours() << " Minutes: " << t2.Minutes() << " Seconds: " << t2.Seconds() << endl;
	--t2;
	t2.write();
	ExtTime e1;
	e1.write();
	++e1;
	e1.write();
	iWatch watch;
	watch.ChinaTime();
	//cout << east8 << endl;
	watch.otherTime(east1);
}